package com.atguigu.gulimall.product.entity;

import com.atguigu.common.valid.AddGroup;
import com.atguigu.common.valid.ListValueVerification;
import com.atguigu.common.valid.UpdateGroup;
import com.atguigu.common.valid.UpdateStatusGroup;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;

import lombok.Builder;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import javax.validation.constraints.*;

/**
 * 品牌
 * 
 * @author GuanMing.Zhu
 * @email xiaoming.080797@gmail.com
 * @date 2020-10-20 20:52:23
 */
@Data
@TableName("pms_brand")
@Builder
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@NotNull(message = "更新时，品牌ID不能为空", groups = UpdateGroup.class)
	@Null(message = "新增品牌时，品牌ID必须为空", groups = AddGroup.class)
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名称不能为空", groups = {AddGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotBlank(message = "品牌logo地址不能为空", groups = AddGroup.class)
	@URL(message = "logo必须是一个合法url地址", groups = {AddGroup.class, UpdateGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(message = "状态字段不能为空", groups = {AddGroup.class, UpdateStatusGroup.class})
	@ListValueVerification(values = {0, 1}, doubleValues = {5d, 6d}, groups = {AddGroup.class, UpdateStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotEmpty(message = "品牌检索首字母不能为空", groups = AddGroup.class)
	@Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须为一个字母", groups = {AddGroup.class, UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "品牌排序字段不能为空", groups = AddGroup.class)
	@Min(value = 0, message = "排序字段必须大于0", groups = {AddGroup.class, UpdateGroup.class})
	private Integer sort;

}
